package com.centaline.httpinvoke;

import com.centaline.invoke.service.TeleiiGateway;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean;

/**
 * Created by caoyuan7 on 2018/2/1.
 * 每一个访问httpinvoke的方法都需要在此处注册
 */
@Configuration
public class TeleiiClientConfiguration {
	@Value("${teleii.client.host.url}")
	private String teleiiRemoteUrl;

	/**
	 * 获取用户信息（DEMO）
	 * @author caoy
	 * @return
	 */
	@Bean(name = "teleiiGatewayClient")
	public TeleiiGateway teleiiGatewayClient() {
		HttpInvokerProxyFactoryBean bean = new HttpInvokerProxyFactoryBean();
		bean.setServiceUrl(teleiiRemoteUrl+"/remote/teleiiGateway");
		bean.setServiceInterface(TeleiiGateway.class);
		//bean.setHttpInvokerRequestExecutor(httpInvokerRequestExecutor);
		bean.afterPropertiesSet();
		return (TeleiiGateway) bean.getObject();
	}
}
